<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    {include file="common/head" /}
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form action="" id="form" class="layui-form" method="post">
            <input type="hidden" name="id" value="{$id|default=0}">

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>拒绝理由
                </label>
                <div class="layui-input-inline">
                    <textarea name="content" id="content" placeholder="请填写拒绝理由" lay-verify="required"
                              class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                {eq name='type' value="0"}
                <button class="layui-btn" lay-filter="add" lay-submit="">
                    立即拒绝
                </button>
                {/eq}
                {eq name='type' value="1"}
                <button class="layui-btn" lay-filter="msg_add" lay-submit="">
                    立即拒绝
                </button>
                {/eq}
                {eq name='type' value="2"}
                <button class="layui-btn" lay-filter="art_add" lay-submit="">
                    立即拒绝
                </button>
                {/eq}
            </div>
        </form>
    </div>
</div>

<script>
    layui.use(['form', 'layer'],
        function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;


            //监听提交
            form.on('submit(add)',function (data) {
                    var txt = $("#content").val();
                    $.ajax({
                        type: "POST",
                        url: "{:url('acStatus')}",
                        data: {id: '{$id}', status: 2, content: txt},
                        dataType: 'json',
                        success: function (result) {
                            if (result.code) {
                                layer.alert(result.msg, {
                                    icon: 6
                                }, function () {
                                    xadmin.close();
                                    xadmin.father_reload();
                                });

                            } else {
                                layer.alert(result.msg, {
                                    icon: 2
                                }, function () {
                                    xadmin.close();
                                });
                            }
                        },
                        error: function (data) {
                            layer.alert(data.msg, {
                                icon: 2
                            }, function () {
                                xadmin.close();
                            });
                        }

                    });

                    return false;
                });

            form.on('submit(msg_add)',function (data) {
                var txt = $("#content").val();
                $.ajax({
                    type: "POST",
                    url: "{:url('msg_status')}",
                    data: {id: '{$id}', status: -1, content: txt},
                    dataType: 'json',
                    success: function (result) {
                        if (result.code) {
                            layer.alert(result.msg, {
                                icon: 6
                            }, function () {
                                xadmin.close();
                                xadmin.father_reload();
                            });

                        } else {
                            layer.alert(result.msg, {
                                icon: 2
                            }, function () {
                                xadmin.close();
                            });
                        }
                    },
                    error: function (data) {
                        layer.alert(data.msg, {
                            icon: 2
                        }, function () {
                            xadmin.close();
                        });
                    }

                });

                return false;
            });

            form.on('submit(art_add)',function (data) {
                var txt = $("#content").val();
                $.ajax({
                    type: "POST",
                    url: "{:url('Article/msg_status')}",
                    data: {id: '{$id}', status: -1, content: txt},
                    dataType: 'json',
                    success: function (result) {
                        if (result.code) {
                            layer.alert(result.msg, {
                                icon: 6
                            }, function () {
                                xadmin.close();
                                xadmin.father_reload();
                            });

                        } else {
                            layer.alert(result.msg, {
                                icon: 2
                            }, function () {
                                xadmin.close();
                            });
                        }
                    },
                    error: function (data) {
                        layer.alert(data.msg, {
                            icon: 2
                        }, function () {
                            xadmin.close();
                        });
                    }

                });

                return false;
            });
        });
</script>

</body>

</html>
